#ifndef INC_MODEL_FRAGMENT_MATCHER_H
#define INC_MODEL_FRAGMENT_MATCHER_H

#include "Fragment.h"

#include <string>
#include <map>

#include "ModelException.h"

#include <iostream>

class AminoacidMatcher
{

    typedef std::string AA_Seq;
    typedef std::string AA_Name;
    std::map<AA_Seq, AA_Name> aa_seq_names;

    AtomElementIndexer& atom_element_indexer;

public:
    AminoacidMatcher(AtomElementIndexer& atom_element_indexer)
        : atom_element_indexer(atom_element_indexer)
    {
		  // TODO: Get this from a config file
        aa_seq_names["NCCOHHHHHHCH"] = "ALA-N";
        aa_seq_names["NCCHOHHHCH"] = "ALA";
		  aa_seq_names["NCCHOHHCHHO"] = "SER";
		  aa_seq_names["NCCHHHCHHOOO"] = "SER-C";
    }

    void match(Fragment* frag) const
    {
        const std::string seq = frag->get_sequence(atom_element_indexer);
		  
		  if (aa_seq_names.find(seq) == aa_seq_names.end())
			  throw ModelException(("Unknown fragment " + seq + " recieved.").c_str());

		  const std::string& frag_name = aa_seq_names.find(seq)->second;
        frag->set_name( frag_name );
    }
};

#endif /* INC_MODEL_FRAGMENT_MATCHER_H */
